package hoang.android.app.json;

import java.io.IOException;
import java.io.InputStream;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class ParserImage {

	public static Bitmap getBitmap(String url) {
		InputStream inputStream = null;
		Bitmap bitmap = null;
		try {
			HttpClient client = new DefaultHttpClient();
			HttpPost get = new HttpPost(url);
			HttpResponse response = client.execute(get);
														
			HttpEntity entity = response.getEntity();
			inputStream = entity.getContent();

			bitmap = BitmapFactory.decodeStream(inputStream);

			inputStream.close();

		} catch (ClientProtocolException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		return bitmap;
	}
}
